package com.hksj.aqm.controller;

import com.hksj.aqm.dto.AqmLargeScreenDTO;
import com.hksj.aqm.dto.ExportAqmDeviceHistoryDTO;
import com.hksj.aqm.service.AqmLargeScreenService;
import com.hksj.aqm.vo.AqmAlarmStatusVO;
import com.hksj.aqm.vo.AqmAlarmTypeVO;
import com.hksj.common.core.model.Rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Api(tags = "空气质量-驾驶舱大屏管理")
@RequestMapping("/aqm/largeScreen")
@RestController
public class AqmLargeScreen {

    @Autowired
    private AqmLargeScreenService aqmLargeScreenService;

    @ApiOperation(value = "报警类型分布（最近7天）")
    @PostMapping("/queryAqmAlarmDeviceByType")
    public Rest<List<AqmAlarmTypeVO>> queryAqmAlarmByType(@RequestBody AqmLargeScreenDTO dto){
        return Rest.ok(aqmLargeScreenService.queryAqmAlarmByType(dto));
    }

    @ApiOperation(value = "报警类型分布-环境管理（最近7天）")
    @PostMapping("/queryAqmAlarmDeviceByType4HJGL")
    public Rest<List<AqmAlarmTypeVO>> queryAqmAlarmDeviceByType4HJGL(@RequestBody AqmLargeScreenDTO dto){
        return Rest.ok(aqmLargeScreenService.queryAqmAlarmDeviceByType4HJGL(dto));
    }

    @ApiOperation(value = "实时报警信息")
    @PostMapping("/queryAqmAlarmStatus")
    public Rest<List<AqmAlarmStatusVO>> queryAqmAlarmStatus(@RequestBody AqmLargeScreenDTO dto){
        return Rest.ok(aqmLargeScreenService.queryAqmAlarmStatus(dto));
    }

    @ApiOperation(value = "设备列表-导出设备历史数据")
    @PostMapping("/exportAqmDeviceHistory")
    public void exportAqmDeviceHistory(@RequestBody ExportAqmDeviceHistoryDTO dto, HttpServletResponse response) throws IOException {
        aqmLargeScreenService.exportAqmDeviceHistory(dto,response);
    }

}
